package comnet.rmi;

import java.rmi.Naming;
import java.rmi.NotBoundException;

/**
 * @author Mikko Puustinen (mikko.puustinen@gmail.com)
 * @version 0.1, 2008-jan-15
 */
public class RmiClientRunner {
    public static void main(String[] args) {
        String host = "localhost";
        if (args.length != 1) {
            //System.out.println("usage: java AuctionClient <server_host>");
            //return;
        }

        try {
            String url = "rmi://" + host + "/RmiChatServer";
            ChatActions server = (ChatActions)Naming.lookup(url);
            ClientActions client = new RmiClient(server, "CoolNick");

            /* Register for callbacks at the auction server.
               */
            server.registerSession(client);

            client.runClient();
        }
        catch (NotBoundException nbe) {
            //System.out.println(nbe.toString());
            System.out.println(host + " is not available");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}